package hasalah.demo.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.maps.client.HasMap;
import com.google.gwt.maps.client.MapOptions;
import com.google.gwt.maps.client.MapTypeId;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.base.LatLng;
import com.google.gwt.maps.client.overlay.Marker;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class MVPDemo implements EntryPoint {
	
	  private MapWidget mapWidget;
	  final private static LatLng CENTER = new LatLng(39.509, -98.434);
	  
	  // GWT module entry point method.
	  public void onModuleLoad() {
		  

		
	    final MapOptions options = new MapOptions();
	    // Zoom level. Required
	    options.setZoom(8);
	    // Open a map centered on Cawker City, KS USA. Required
	    options.setCenter(new LatLng(39.509, -98.434));
	    // Map type. Required.
	    options.setMapTypeId(new MapTypeId().getRoadmap());
	    
	    // Enable maps drag feature. Disabled by default.
	    options.setDraggable(true);
	    // Enable and add default navigation control. Disabled by default.
	    options.setNavigationControl(true);
	    // Enable and add map type control. Disabled by default.
	    options.setMapTypeControl(true);
	    mapWidget = new MapWidget(options);
	    mapWidget.setSize("800px", "600px");
	    	    
	    Marker marker = new Marker();
	    marker.setPosition(CENTER);
	    marker.setMap(getMap());
	    marker.setTitle("Hello World!");
	    marker.setDraggable(true);
	    
	    Label longLabel = new Label("Long: ");
	    TextBox longTextBox = new TextBox();
	    Label latLabel = new Label("Lat: ");
	    TextBox latTextBox  = new TextBox();
	    	    
	    FlexTable customTable = new FlexTable();
	    
	    customTable.setWidget(1, 1, longLabel);
	    customTable.setWidget(1, 2, longTextBox);
	    customTable.setWidget(2, 1, latLabel);
	    customTable.setWidget(2, 2, latTextBox);
	       
	   
	    // Add the map to the HTML host page
	    RootPanel.get("mapsTutorial").add(mapWidget);
	    
	    RootPanel.get("options").add(customTable);
	  }
	  
	  public HasMap getMap() {
	    return mapWidget.getMap();
	  }

}
